package com.aspose.cells;

import java.awt.print.Book;
import java.awt.print.PageFormat;
import java.awt.print.Paper;
import java.awt.print.PrinterJob;
import java.util.Locale;
import javax.print.DocFlavor;
import javax.print.PrintService;
import javax.print.PrintServiceLookup;
import javax.print.attribute.HashAttributeSet;
import javax.print.attribute.standard.PrinterName;

class zho {
   zbuz a;
   String b;
   String c;

   public zho(String var1, zbuz var2) {
      this.a = var2;
      this.b = var1;
   }

   public zho(String var1, String var2, zbuz var3) {
      this.a = var3;
      this.b = var1;
      this.c = var2;
   }

   public void a() throws Exception {
      PrinterJob var1 = PrinterJob.getPrinterJob();
      Book var2 = new Book();
      int var3 = -1;

      for(int var4 = 0; var4 < this.a.c.size(); ++var4) {
         zan var5 = (zan)this.a.c.get(var4);
         PageFormat var6 = new PageFormat();
         Worksheet var7 = var5.b;
         int var8 = var7.getPageSetup().getOrientation();
         if (var8 == 0) {
            var6.setOrientation(0);
         } else {
            var6.setOrientation(1);
         }

         Paper var9 = new Paper();
         var9.setSize(var5.x[0], var5.x[1]);
         var9.setImageableArea(0.0D, 0.0D, var5.x[0], var5.x[1]);
         var6.setPaper(var9);
         boolean var10 = false;
         if (var5.b.m() != var3 && var3 != -1) {
            var10 = true;
         }

         var3 = var5.b.m();
         zaso var11 = new zaso(var5, (com.aspose.cells.a.d.zat)((com.aspose.cells.a.d.zat)this.a.a), var10);
         var2.append(var11, var6);
      }

      if (this.a.c.size() > 0) {
         zan var12 = (zan)this.a.c.get(0);
         var1.setPageable(var2);
         HashAttributeSet var13 = new HashAttributeSet();
         var13.add(new PrinterName(this.b, (Locale)null));
         PrintService[] var14 = PrintServiceLookup.lookupPrintServices((DocFlavor)null, var13);
         if (var14.length == 0) {
            throw new Exception("Can't find the printer");
         }

         if (this.c != null && this.c.length() > 0) {
            var1.setJobName(this.c);
         }

         var1.setPrintService(var14[0]);
         var1.print();
      }

   }
}
